<?php
class regControl extends Control{
	public function index(){
		$this->display();
	}
  public function reg(){
    
  	
  	if(!$_POST['code']==$_SESSION['code']){
    	$this->error('验证码错误');
    	 exit;
    	}   
  	   $db=M('user');
       $user=$_POST['username'];
      
  	   if($db->where("username='{$user}'")->select()){
  	  	$this->error('用户名已存在');
    	 exit;
  	  }
    	$_POST['regtime']=time();
  	  $_POST['password']=md5($_POST['password']);
    	if(isset($_POST['imgs']))
    	{$_POST['imgs']=$_POST['imgs'][1][0];
    	}
  	  if($db->add()){
			$_SESSION['user']['username']=$_POST['username'];
    		
			$this->success('注册成功','index/index');
    		
			
		}
		else{
			$this->error('注册失败请重新填写');
		}
   


  }

}

?>